
import {Component, ElementRef, ViewChild} from "@angular/core";
import {IonicPage, NavController} from "ionic-angular";
import {HttpService} from "../../../providers/HttpService";
import {NativeServiceC} from "../../../providers/NativeServiceC";

@IonicPage()
@Component({
  selector: 'page-themeBook',
  templateUrl: 'themeBook.html'
})

export class ThemeBookPage {

  BookList=[];
  private ThemeBookUrl= '/book-list';

  constructor(public navCtrl: NavController,
              public httpServe:HttpService,
              public nativeService:NativeServiceC,
              public privateElementRef: ElementRef) {

  }


  //改变字体颜色
  @ViewChild('week')
  greetWeek: ElementRef;
  ngAfterViewInitWeekRed() {
    this.greetWeek.nativeElement.style.color ='red';
  }
  ngAfterViewInitWeekBlack() {
    this.greetWeek.nativeElement.style.color ='#333333';
  }

  @ViewChild('new')
  greetNew: ElementRef;
  ngAfterViewInitNewRed() {
    this.greetNew.nativeElement.style.color ='red';
  }
  ngAfterViewInitNewBlack() {
    this.greetNew.nativeElement.style.color ='#333333';
  }

  @ViewChild('more')
  greetMore: ElementRef;
  ngAfterViewInitMoreRed() {
    this.greetMore.nativeElement.style.color ='red';
  }
  ngAfterViewInitMoreBlack() {
    this.greetMore.nativeElement.style.color ='#333333';
  }

  ionViewDidLoad(){
    this.ngAfterViewInitWeekRed();
    let classify = '';
   this.searchBook(classify);
  }


//本周最热
  searchWeekHot(){
    this.ngAfterViewInitWeekRed();
    this.ngAfterViewInitNewBlack();
    this.ngAfterViewInitMoreBlack();
    let classify = '';
    this.searchBook(classify);
  }

//最先发布
  searchNewIssue(){
    this.ngAfterViewInitNewRed();
    this.ngAfterViewInitWeekBlack();
    this.ngAfterViewInitMoreBlack();
    let NewIssue = '';
    this.searchBook(NewIssue);
  }

//最多收藏
  searchMoreCollect(){
    this.ngAfterViewInitMoreRed();
    this.ngAfterViewInitNewBlack();
    this.ngAfterViewInitWeekBlack();
    let MoreCollect = '';
    this.searchBook(MoreCollect);
  }


  private searchBook (temp){
    this.httpServe.get(this.ThemeBookUrl + temp).subscribe(res=>{
      this.BookList = res;
      console.log(this.BookList);
      this.nativeService.hideLoading();
    })
  }

}
